/**
 * 
 */
package org.mhz.ootw.controller;

import javax.annotation.Resource;

import org.mhz.ootw.service.ContentsService;
import org.mhz.ootw.util.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Mahan
 *
 * Show contents controller
 */
@Controller
public class ShowContentsController
{
    private static final Logger LOGGER = LoggerFactory.getLogger(ShowContentsController.class);

    @Resource(name = Constants.REPOSITORY_CONTENTS_SERVICE)
    private ContentsService mRepositoryContentsService;
    
    /**
     * Handles request for showing the contents of a readable item
     * 
     * @param aNodeId - The node id
     * @return The contents of the file
     */
    @RequestMapping(value = Constants.SHOW_CONTENTS, method = RequestMethod.GET)
    public @ResponseBody String showContents(
            @RequestParam(value = Constants.NODE_ID, required = true) final String aNodeId)
    {
        final String contents = mRepositoryContentsService.getContents(aNodeId);
        
        return contents;
    }
}
